package org.jeecg.modules.demo.report3.service.impl;

import org.jeecg.modules.demo.report1.entity.Xin;
import org.jeecg.modules.demo.report3.entity.Qianshou;
import org.jeecg.modules.demo.report3.mapper.QianshouMapper;
import org.jeecg.modules.demo.report3.service.IQianshouService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

import static kotlin.reflect.jvm.internal.impl.builtins.StandardNames.FqNames.list;

/**
 * @Description: 应收报表
 * @Author: jeecg-boot
 * @Date:   2024-04-01
 * @Version: V1.0
 */
@Service
public class QianshouServiceImpl extends ServiceImpl<QianshouMapper, Qianshou> implements IQianshouService {
    @Override
    public Xin setTotalValue(List<Qianshou> list) {
        Xin zong = new Xin();
        zong.setPublicSanitation(list.stream()
                .filter(q -> q.getPublicSanitation() != null) // 过滤掉 PublicSanitation 为空的对象
                .mapToDouble(Qianshou::getPublicSanitation)  // 获取每个对象的 PublicSanitation 属性值，并转换为 double 类型
                .sum());
        zong.setPropertyManagement(list.stream()
                .filter(q -> q.getPropertyManagement() != null)
                .mapToDouble(Qianshou::getPropertyManagement)
                .sum());

        zong.setPropertyManagementSix(list.stream()
                .filter(q -> q.getPropertyManagementSix() != null)
                .mapToDouble(Qianshou::getPropertyManagementSix)
                .sum());

        zong.setPipelinePressurizationfee(list.stream()
                .filter(q -> q.getPipelinePressurizationfee() != null)
                .mapToDouble(Qianshou::getPipelinePressurizationfee)
                .sum());

        zong.setParkingServices(list.stream()
                .filter(q -> q.getParkingServices() != null)
                .mapToDouble(Qianshou::getParkingServices)
                .sum());

        zong.setWater(list.stream()
                .filter(q -> q.getWater() != null)
                .mapToDouble(Qianshou::getWater)
                .sum());

        zong.setTotalBill(list.stream()
                .filter(q -> q.getTotalBill() != null)
                .mapToDouble(Qianshou::getTotalBill)
                .sum());
        return zong;
    }
}
